<?php 

	$host = "localhost"; 
	$user = "root"; 
	$pass = ""; 
	$database = "atpchat"; 
	$linkID = new PDO("mysql:host=".$host.";dbname=".$database, $user, $pass);
	$sth = $linkID->query("SELECT * FROM chat c INNER JOIN user u ON c.utilisateur=u.iduser ORDER BY c.idmessage");
	$rows = array();
	while ($r = $sth->fetch(PDO::FETCH_OBJ)) {
	   $rows[] = $r;
	}
	$json=json_encode($rows);
	echo $json;

?>

